package com.hfi.controller;

import com.hfi.aop.Encoreable;
import com.hfi.aop.Performance;
import com.hfi.aop2.BlankDisc;
import com.hfi.interceptor2.HfiTrace;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author ChangLiang
 * @date 2019/6/6
 */
@RestController
public class AopController {

    @Autowired
    private Performance performance;

    @Autowired
    private BlankDisc blankDisc;

    @HfiTrace
    @GetMapping("/perform")
    public String perform() {
        String perform = performance.perform();
        return perform;
    }

    @HfiTrace(name = "abc")
    @GetMapping("/performEncore")
    public String performEncore() {
        // 强制转换
        Encoreable encoreable = (Encoreable) performance;
        return encoreable.performEncore();
    }

    @GetMapping("playTrack")
    public String playTrack(String track) {
        return blankDisc.playTrack(track);
    }
}